<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>组织生活签到</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
/* 			$.ajax({
			      async: true,
			      type: "HEAD",//get 方式猎豹有问题
			      success: function(result, status, xhr) {
			      var date = new Date( xhr.getResponseHeader("Date"));
			      alert(date);
			     }
			}); */
			
			
			$("#checkAll").on('click', function() {
				//复选框
				var ch = this.checked;
				if (ch) {
					$("input[name='ids']").prop("checked", true);
				} else {
					$("input[name='ids']").prop("checked", false);
				}
			});
			getCheckList = function() {
				var ids = [];
				$("input[name='ids']:checked").each(function() {
					ids.push($(this).val());
				});
				return ids;
			}
			
			$("#btnQuery").on('click', function() {
				var ids = getCheckList();
				if (ids.length < 1) {					
					top.$.jBox.confirm("请选择一条记录查看！","系统提示",function(v,h,f){
					
					},{buttonsFocus:1});
					top.$('.jbox-body .jbox-icon').css('top','55px');					
					return false;
				}else if (ids.length > 1) {
					top.$.jBox.confirm("请选择一条记录查看！","系统提示",function(v,h,f){
						
					},{buttonsFocus:1});
					top.$('.jbox-body .jbox-icon').css('top','55px');					
					return false;
				}
				$("#searchForm").attr("action","${ctx}/life/organizeLifeQd/form?id="+ids);
				$("#searchForm").submit();
				
			});
			
			$("#btnQd").on('click', function() {
				$.ajax({
					type : 'POST',
					url : "${ctx}/life/organizeLife/checkOrgSatate",
					type : "get",
					dataType : "json",
					async : false,//同步  
					success : function(result) {		
						if(result.type == "success"){
							var ids = getCheckList();
							if (ids.length < 1) {					
								top.$.jBox.confirm("请选择一条记录签到！","系统提示",function(v,h,f){
								
								},{buttonsFocus:1});
								top.$('.jbox-body .jbox-icon').css('top','55px');					
								return false;
							}else if (ids.length > 1) {
								top.$.jBox.confirm("请选择一条记录签到！","系统提示",function(v,h,f){
									
								},{buttonsFocus:1});
								top.$('.jbox-body .jbox-icon').css('top','55px');					
								return false;
							}
							
							$("#searchForm").attr("action","${ctx}/life/organizeLifeQd/personQd?id="+ids);
							$("#searchForm").submit();
						} else {
							top.$.jBox.error("当前支部未开通！","系统提示",function(v,h,f){
							
							},{buttonsFocus:1});
							top.$('.jbox-body .jbox-icon').css('top','55px');
														
						}
					}
				});		
				
			});
				
		});
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

	</script>
</head>
<body>
		<ul class="nav nav-tabs">
		<li class="active"><a>组织生活签到</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="organizeLife" action="${ctx}/life/organizeLifeQd/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
		    <li><label>活动名称：</label>
				<form:input path="lifename" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label style="margin-left: -20px;">分类：</label>
				<form:select path="typeids" class="input-medium" >
							<form:option value="" label="全部"/>
							<form:options items="${organizeLifeTypes}" itemLabel="typename" itemValue="id" htmlEscape="false"/>
						</form:select>
			</li>

			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<!-- 
			<li class="btns"><input id="btnQuery" class="btn btn-primary" type="button" value="查看"/></li>
			 -->
			<li class="btns"><input id="btnQd" class="btn btn-primary" type="button" value="签到"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			    <th width="2%" style='text-align: center'><input
					type="checkBox" id="checkAll" /></th>
				<th style="width:3%">序号</th>	
				<th style="width:40%">活动名称</th>
				<th style="width:10%">分类</th>
				<th style="width:5%">审核状态</th>
				<th style="width:10%">计划时间</th>
				<th style="width:15%">活动地点</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="organizeLife" varStatus="rowIndex">
			<tr>
			    <td style='text-align: center'><input type='checkbox' id='ids' name='ids' value='${organizeLife.id}' /></td>
		        <td style='text-align: center'>${rowIndex.index+1}</td>		    
				<td><a href="${ctx}/life/organizeLifeQd/form?id=${organizeLife.id}">
					${organizeLife.lifename}
				</a></td>
				<td>
					<div style="width:150px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" 
					title="${organizeLife.typeids}">${organizeLife.typeids}</div>
				</td>
				<td style='text-align: center'>
					${fns:getDictLabel(organizeLife.shstate, 'life_approve_status', '')}
				</td>
				<td style='text-align: center'>
					<fmt:formatDate value="${organizeLife.jhtime}" pattern="yyyy-MM-dd HH:mm"/>
				</td>
				<td>
				<div style="width:200px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" 
					title="${organizeLife.adress}">${organizeLife.adress}</div>
				</td>
				
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>